package cn.itlemon.security.core.entity.common;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author jiangpingping
 * @date 2019/9/18 21:35
 */
@Data
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ReturnMessage<T> {

    /**
     * 返回状态
     */
    private ReturnState state;

    /**
     * 返回数据
     */
    private T data;

    /**
     * 返回消息
     */
    private String message;

    /**
     * 错误码，错误时使用
     */
    private String errorCode;

    /**
     * 错误消息，错误时使用
     */
    private String errorMessage;

    public ReturnMessage(ReturnState state) {
        this.state = state;
    }

    public ReturnMessage(ReturnState state, T data) {
        this(state);
        this.data = data;
    }

    public ReturnMessage(ReturnState state, T data, String message) {
        this(state, data);
        this.message = message;
    }

    public ReturnMessage(ReturnState state, String errorCode) {
        this.state = state;
        this.errorCode = errorCode;
    }

    public ReturnMessage(ReturnState state, String errorCode, String errorMessage) {
        this(state, errorCode);
        this.errorMessage = errorMessage;
    }

}
